﻿using System;
using System.Collections.Generic;
using System.Text;
using DotNet.Data;
using DotNet.Model;
using System.Data;
namespace DotNet.Business
{
	public class QuestionBll
	{
		QuestionDal qDal=new QuestionDal();

		#region 是否存在该记录
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int QuestionID)
		{
			return qDal.Exists(QuestionID);
		}
		#endregion

		#region 根据父id获得数据列表---郑同飞
		/// <summary>
        /// 根据父id获得数据列表---郑同飞
        /// <param name="fid">父id(如果fid为0则是父问题)</param>
		/// </summary>
		public IList<Question> GetModelByFid(int fid)
		{
            return qDal.GetModelByFid(fid);
		}
		#endregion

		#region 根据标识列获得数据实体
		/// <summary>
		/// 根据标识列获得数据实体
		/// </summary>
		/// <param name="QuestionID">标识列</param>
        /// <param name="fid">父id</param>
		/// <returns></returns>
		public Question GetModel(int questionID)
		{
            return qDal.GetModel(questionID);
		}
		#endregion

        #region 根据问题类别id得到该类别下的问题数量---郑同飞
        /// <summary>
        /// 根据问题类别id得到该类别下的问题数量---郑同飞
        /// </summary>
        /// <param name="questi0nClassID">问题类别id</param>
        /// <returns></returns>
        public int getCountByQcID(int questi0nClassID)
        {
            return qDal.getCountByQcID(questi0nClassID);
        }
        #endregion

        #region 修改信息
        /// <summary>
		/// 修改信息
		/// </summary>
		/// <param name="Question">实体</param>
		/// <returns></returns>
		public bool Update(Question question)
		{
			 return qDal.Update(question);
		}
		#endregion

        #region ajax批量修改
        /// <summary>
        /// ajax批量修改
        /// </summary>
        /// <param name="qid"></param>
        /// <param name="classid"></param>
        /// <returns></returns>
        public bool Update(string[] qid,string classid)
        {
            return qDal.Update(qid, classid);
        }
        #endregion

        #region 删除信息
        /// <summary>
		/// 删除信息
		/// </summary>
		/// <param name="QuestionID">标识列</param>
		/// <returns></returns>
		public bool Delete(int QuestionID)
		{
			 return qDal.Delete(QuestionID);
		}
		#endregion

        #region 根据用户名删除信息---郑同飞
        /// <summary>
        /// 根据用户名删除信息---郑同飞
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public bool Delete(string userName)
        {
            return qDal.Delete(userName);
        }
        #endregion

        #region 根据父id删除问题
        /// <summary>
        /// 根据父id删除问题
        /// </summary>
        /// <param name="fid">父id</param>
        /// <returns></returns>
        public bool DeleteByFid(int fid)
        {
           return qDal.DeleteByFid(fid);
        }
        #endregion

        #region 添加信息
        /// <summary>
		/// 添加信息
		/// </summary>
		/// <param name="Question">实体</param>
		/// <returns></returns>
		public bool Insert(Question question)
		{
			 return qDal.Insert(question);
		}
		#endregion

        #region 问题前台分页---郑同飞
        /// <summary>
        /// 问题前台分页---郑同飞
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="questionClassID"></param>
        /// <returns></returns>
        public DataTable pagingForQuestions(int pageIndex,int pageSize,string userName,int questionClassID,string productid,int? questionState) 
        {

            return qDal.pagingForQuestion(pageIndex, pageSize, userName, questionClassID, productid, questionState);

        }
        #endregion

        #region 根据用户id获取问题的数量---郑同飞
        /// <summary>
        /// 根据用户id获取问题的数量---郑同飞
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public int getRecordCount(string userName,int questionclassid,string productid,int? questionState)
        {

            return qDal.getRecordCount(userName, questionclassid, productid, questionState);            
        }
        #endregion

        #region 根据问题id获取最近提问--郑同飞
        /// <summary>
        /// 根据问题id获取最近提问--郑同飞
        /// </summary>
        /// <param name="qidList"></param>
        /// <returns></returns>
        public IList<Question> getLastQuestion(IList<int> qidList)
        {
            return qDal.getLastQuestion(qidList);
        }
        #endregion


    }
}
